{$CLEO .cs}
{$USE CLEO+}
{$USE ini}

0000: NOP

script_name "WD Pistol"

// By ArtemQa146

if
    0AA2: 31@ = load_dynamic_library "CLEO+.cleo"
then
    if
        0AA4: 30@ = get_dynamic_library_procedure "GetCleoPlusVersion" library 31@
    then
        0AA7: call_function_return 30@ num_params 0 pop 0 29@
        if
            not 29@ >= 0x1020000
        then
            0AD1: show_formatted_text_highpriority "Cleo+ 1.2.0 (or higher) version is required, the Weapon Details mod is disabled" time 15000
            0AA3: free_dynamic_library 31@
            0A93: terminate_this_custom_script
        end
        0AA3: free_dynamic_library 31@
    end
else
    0AD1: show_formatted_text_highpriority "Cleo+ 1.2.0 (or higher) version is required, the Weapon Details mod is disabled" time 15000
    0AA3: free_dynamic_library 31@
    0A93: terminate_this_custom_script
end

if
    0E2D: is_game_first_start
then
    0F00: load_special_model_dff "colt45\colt45_S" txd "colt45\colt45" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "colt45_S"
    0F00: load_special_model_dff "colt45\colt45_R" txd "colt45\colt45" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "colt45_R"
    0F00: load_special_model_dff "colt45\colt45_O" txd "colt45\colt45" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "colt45_O"
    0F00: load_special_model_dff "Silenced\Silenced_S" txd "Silenced\Silenced" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "Silenced_S"
    0F00: load_special_model_dff "Silenced\Silenced_R" txd "Silenced\Silenced" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "Silenced_R"
    0F00: load_special_model_dff "Silenced\Silenced_O" txd "Silenced\Silenced" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "Silenced_O"
    0F00: load_special_model_dff "deagle\desert_eagle_S" txd "deagle\desert_eagle" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "desert_eagle_S"
    0F00: load_special_model_dff "deagle\desert_eagle_R" txd "deagle\desert_eagle" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "desert_eagle_R"
    0F00: load_special_model_dff "deagle\desert_eagle_O" txd "deagle\desert_eagle" store_to 0@
    0AF1: write_int 0@ to_ini_file "cleo\LoadModels.ini" section "Models" key "desert_eagle_O"
end

const
    colt45_s = 31@
    colt45_r = 30@
    colt45_o = 29@
    cl_Clip_Model = 28@
    cl_Clip_X = 27@
    cl_Clip_Y = 26@
    cl_Clip_Z = 25@
    colt45_s2 = 24@
    colt45_r2 = 23@
    colt45_o2 = 22@
    silenced_s = 21@
    silenced_r = 20@
    silenced_o = 19@
    sl_Clip_Model = 18@
    sl_Clip_X = 17@
    sl_Clip_Y = 16@
    sl_Clip_Z = 15@
    
    deagle_s = 14@
    deagle_r = 13@
    deagle_o = 12@
    deagle_Clip_Model = 11@
    deagle_Clip_X = 10@
    deagle_Clip_Y = 9@
    deagle_Clip_Z = 8@
end

repeat
wait 0
until player.Defined(0)

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "colt45_S"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale colt45_s // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0F02:  $PLAYER_ACTOR special_model 0@ bone 34 offset 0.03 0.03 0 rotation 0 180.0 180.0 scale colt45_s2 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF2: cl_Clip_X = get_float_from_ini_file "cleo\colt45.ini" section "settings" key "Clip X"
0AF2: cl_Clip_Y = get_float_from_ini_file "cleo\colt45.ini" section "settings" key "Clip Y"
0AF2: cl_Clip_Z = get_float_from_ini_file "cleo\colt45.ini" section "settings" key "Clip Z"
0AF0: cl_Clip_Model = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "colt45_R"
0F02:  $PLAYER_ACTOR special_model cl_Clip_Model bone 24 offset cl_Clip_X cl_Clip_Y cl_Clip_Z rotation 0 0 0 scale colt45_r // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0AF2: 1@ = get_float_from_ini_file "cleo\colt45.ini" section "settings" key "Clip X2"
0AF2: 2@ = get_float_from_ini_file "cleo\colt45.ini" section "settings" key "Clip Y2"
0AF2: 3@ = get_float_from_ini_file "cleo\colt45.ini" section "settings" key "Clip Z2"
0F02:  $PLAYER_ACTOR special_model cl_Clip_Model bone 34 offset 1@ 2@ 3@ rotation 0 180.0 180.0 scale colt45_r2 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "colt45_O"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale colt45_o // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
0F02:  $PLAYER_ACTOR special_model 0@ bone 34 offset 0.03 0.03 0 rotation 0 180.0 180.0 scale colt45_o2 // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "Silenced_S"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale silenced_s // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF2: sl_Clip_X = get_float_from_ini_file "cleo\Silenced.ini" section "settings" key "Clip X"
0AF2: sl_Clip_Y = get_float_from_ini_file "cleo\Silenced.ini" section "settings" key "Clip Y"
0AF2: sl_Clip_Z = get_float_from_ini_file "cleo\Silenced.ini" section "settings" key "Clip Z"
0AF0: sl_Clip_Model = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "Silenced_R"
0F02:  $PLAYER_ACTOR special_model sl_Clip_Model bone 24 offset sl_Clip_X sl_Clip_Y sl_Clip_Z rotation 0 0 0 scale silenced_r // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
sl_Clip_Y += 0.03
sl_Clip_Z -= 0.013

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "Silenced_O"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale silenced_o // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "desert_eagle_S"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale deagle_s // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0AF2: deagle_Clip_X = get_float_from_ini_file "cleo\Deagle.ini" section "settings" key "Clip X"
0AF2: deagle_Clip_y = get_float_from_ini_file "cleo\Deagle.ini" section "settings" key "Clip Y"
0AF2: deagle_Clip_z = get_float_from_ini_file "cleo\Deagle.ini" section "settings" key "Clip Z"
0AF0: deagle_Clip_Model = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "desert_eagle_R"
0F02:  $PLAYER_ACTOR special_model deagle_Clip_Model bone 24 offset deagle_Clip_X deagle_Clip_y deagle_Clip_z rotation 0 0 0 scale deagle_r // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors
deagle_Clip_y += 0.03
deagle_Clip_z -= 0.013

0AF0: 0@ = read_int_from_ini_file "cleo\LoadModels.ini" section "Models" key "desert_eagle_O"
0F02:  $PLAYER_ACTOR special_model 0@ bone 24 offset 0 0 0 rotation 0 0 0 scale deagle_o // bone 34 left hand, 24 right hand, 9 had, 3 tors, 4 upper tors

0E31: set_render_object_visible colt45_s 0
0E31: set_render_object_visible colt45_s2 0
0E31: set_render_object_visible colt45_o 0
0E31: set_render_object_visible colt45_o2 0
0E31: set_render_object_visible colt45_r 0
0E31: set_render_object_visible colt45_r2 0

0E31: set_render_object_visible silenced_s 0
0E31: set_render_object_visible silenced_r 0
0E31: set_render_object_visible silenced_o 0

0E31: set_render_object_visible deagle_s 0
0E31: set_render_object_visible deagle_r 0
0E31: set_render_object_visible deagle_o 0


while true
wait 0
    if
        player.Defined(0)
    then
        if
            actor.Driving($PLAYER_ACTOR)
        then
            continue
        end

        0AAA: 1@ = get_script_struct_named 'Col45'
        if and
            02D8:   actor $PLAYER_ACTOR current_weapon == 22
            1@ == 0
        then
            0A92: stream_custom_script "Colt45.qa" colt45_s colt45_r colt45_o cl_Clip_Model cl_Clip_X cl_Clip_Y cl_Clip_Z colt45_s2 colt45_r2 colt45_o2
            timera = 0
            repeat
            wait 0
            if timera > 500
            then break
            end
            0AAA: 1@ = get_script_struct_named 'Col45'
            until 1@ > 0
            continue
        end
        
        0AAA: 1@ = get_script_struct_named 'Slnced'
        if and
            02D8:   actor $PLAYER_ACTOR current_weapon == 23
            1@ == 0
        then
            0A92: stream_custom_script "Silenced.qa" silenced_s silenced_r silenced_o sl_Clip_Model sl_Clip_X sl_Clip_Y sl_Clip_Z
            timera = 0
            repeat
            wait 0
            if timera > 500
            then break
            end
            0AAA: 1@ = get_script_struct_named 'Slnced'
            until 1@ > 0
            continue
        end
        
        0AAA: 1@ = get_script_struct_named 'Deagle'
        if and
            02D8:   actor $PLAYER_ACTOR current_weapon == 24
            1@ == 0
        then
            0A92: stream_custom_script "Deagle.qa" deagle_s deagle_r deagle_o deagle_Clip_Model deagle_Clip_X deagle_Clip_y deagle_Clip_z
            timera = 0
            repeat
            wait 0
            if timera > 500
            then break
            end
            0AAA: 1@ = get_script_struct_named 'Deagle'
            until 1@ > 0
            continue
        end

    end
end